Package com.serotonin.m2m2.virtual.rt

Source Code of com.serotonin.m2m2.virtual.rt.RandomAnalogChangeRT

/*
    Copyright (C) 2014 Infinite Automation Systems Inc. All rights reserved.
    @author Matthew Lohbihler
*/
package com.serotonin.m2m2.virtual.rt;

import com.serotonin.m2m2.rt.dataImage.types.DataValue;
import com.serotonin.m2m2.rt.dataImage.types.NumericValue;
import com.serotonin.m2m2.virtual.vo.RandomAnalogChangeVO;

public class RandomAnalogChangeRT extends ChangeTypeRT {
    private final RandomAnalogChangeVO vo;

    public RandomAnalogChangeRT(RandomAnalogChangeVO vo) {
        this.vo = vo;
    }

    @Override
    public DataValue change(DataValue currentValue) {
        double newValue = RANDOM.nextDouble();
        return new NumericValue((vo.getMax() - vo.getMin()) * newValue + vo.getMin());
    }
}
TOP

Related Classes of com.serotonin.m2m2.virtual.rt.RandomAnalogChangeRT

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.